<div class='buttons-holder' style="text-align: right;">
    <?php if ($user->getNivel() > 0) {?>
        <?php if($chamado->getStatus()->getId() == 0 || $chamado->getStatus()->getId() == 2) {?>
        <a href="<?=$baseUrl?>chamado/atender/<?=$chamado->getId()?>">
            <input type="submit" value="Atender" />
        </a>
        <?php } ?>
        <?php if($user->getNivel() < 3) {?>
        <a href="<?=$baseUrl?>chamado/repassar/<?=$chamado->getId()?>">
            <input type="submit" value="Repassar" />
        </a>
        <?php } ?>
    <?php } ?>
    <?php if ($user == $chamado->getUsuario()) { ?>
        <?php if($chamado->getStatus()->getId() == 0) {?>
        <a href="<?=$baseUrl?>chamado/editar/<?=$chamado->getId()?>">
            <input type="submit" value="Editar" />
        </a>
        <?php } ?>
        <?php if($chamado->getStatus()->getId() != 3 && $chamado->getStatus()->getId() != 4) {?>
        <a class='confirm' href="<?=$baseUrl?>chamado/cancelar/<?=$chamado->getId()?>">
            <input type="submit" value="Cancelar" />
        </a>
        <a class='confirm' href="<?=$baseUrl?>chamado/resolver/<?=$chamado->getId()?>">
            <input type="submit" value="Marcar como resolvido" />
        </a>
        <?php } ?>
    <?php } ?>
</div>
<h1>Detalhes do chamado</h1>
<div class="dados-holder">
    <div class="right">
        <div><?=$chamado->getServico()->getDescricao()?> - &lt;<?=$chamado->getServico()->getDificuldade()?>&gt;</div>
        <div><a href='<?=$baseUrl?>usuario/ver/<?=$chamado->getUsuario()->getId()?>'><?=$chamado->getUsuario()->getNome()?></a></div>
        <div><?=date_format($chamado->getDataAbertura(), 'd/m/Y - H:i:s')?></div>
        <div><?=$chamado->getStatus()->getDescricao()?></div>
        <div><?=$chamado->getDescricao()?></div>
    </div>
    <div class="left">
        <div>Servi&ccedil;o</div>
        <div>Usu&aacute;rio solicitante</div>
        <div>Data de abertura</div>
        <div>Status</div>
        <div>Descri&ccedil;&atilde;o</div>
    </div>
</div>
<?php if($chamado->getStatus()->getId() != 0) {?>
    <h2>Intera&ccedil;&otilde;es</h2>
    <?php foreach($fluxos as $key=>$fluxo) {?>
        <div class='dados-holder'>
            <div class="right">
                <div><a href='<?=$baseUrl?>usuario/ver/<?=$fluxo->getUsuarioResponsavel()->getId()?>'><?=$fluxo->getUsuarioResponsavel()->getNome()?></a></div>
                <div><?=date_format($fluxo->getData(), 'd/m/Y - H:i:s')?></div>
                <div>
                    <?php foreach($procedimentos[$fluxo->getId()] as $procedimento) { ?>
                        <div>
                            <?= $procedimento->getDescricao() ?>
                            <br />
                            <?php if(!empty($ics[$fluxo->getId()][$procedimento->getId()])) { ?>
                                ICs:                            
                                <?php foreach($ics[$fluxo->getId()][$procedimento->getId()] as $procxic) { ?>
                                    <strong title='<?= $procxic->getIc()->getId().'-'.$procxic->getIc()->getDescricao() ?>'><?= $procxic->getIc()->getNome() ?></strong> - 
                                <?php } ?>
                            <?php }?>
                        </div>
                    <?php } ?>
                </div>
                <?php if ($chamado->getStatus()->getId() != 4
                        && $chamado->getStatus()->getId() != 3
                        && $key == count($fluxos) - 1 
                        && $fluxo->getUsuarioResponsavel() == $user) { ?>
                    <div style='position: absolute; right: 2px; bottom: 2px;'>
                        <a href='<?=$fluxo->getId()?>' class='add-procedimento'>
                            <input type='submit' value='Adicionar procedimento' />
                        </a>
                    </div>
                <?php } ?>
            </div>
            <div class="left">
                <div>Usu&aacute;rio respons&aacute;vel</div>
                <div>Data da intera&ccedil;&atilde;o</div>
                <div>Procedimentos</div>
            </div>
        </div>
    <?php } ?>
<?php } ?>

<?php if(empty($chamados)) {?>
<h4>Nenhum chamado similar encontrado</h4>    
<?php } else { ?>
<h2>Chamados similares</h2>
<table>
    <thead>
        <tr>
            <td>Id</td>
            <td>Descri&ccedil;&atilde;o</td>
            <td>Data</td>
        </tr>
    </thead>
    <?php foreach($chamados as $chamado){ ?>
    <tr>
        <td>
            <a href="<?=$baseUrl?>chamado/ver/<?=$chamado->getId()?>">
                <?=$chamado->getId()?>
            </a>
        </td>
        <td>
            <a href="<?=$baseUrl?>chamado/ver/<?=$chamado->getId()?>">
                <?=$chamado->getDescricao()?>
            </a>
        </td>
        <td>
            <a href="<?=$baseUrl?>chamado/ver/<?=$chamado->getId()?>">
                <?=date_format($chamado->getDataAbertura(), 'd/m/Y')?>
            </a>
        </td>
    </tr>
    <?php } ?>
</table>
<?php } ?>